<?php
function GetDispatchedLaptops()
{
$sql = mysql_query("SELECT DISTINCT usr.user_no, usr.user_firstname, usr.user_lastname,usr.user_designation, lpt.division , lpt.laptopmodel, lpt.depot, lpt.dispatch_date, lpt.laptop_id,lpt.serial_no FROM users AS usr INNER JOIN laptop AS lpt ON usr.user_id = lpt.user_id LEFT JOIN return_laptop AS rl ON lpt.laptop_id = rl.laptop_id WHERE lpt.dispatch = 1 AND  rl.laptop_id IS NULL ORDER BY usr.user_no ASC"); 

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Designation</b></th>					
						<th><b>Division</b></th>
						<th><b>Depot</b></th>					
						<th><b>Laptop Model</b></th>
						<th><b>Serial No</b></th>
						<th><b>Box No</b></th>
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['user_designation'].'</td>
						<td align="center">'.$result['division'].'</td>					
						<td align="center">'.$result['depot'].'</td>
						<td align="center">'.$result['laptopmodel'].'</td>
						<td align="center">'.$result['serial_no'].'</td>
						<td align="center">'.GetBoxno($result['serial_no']).'</td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}



//added by bhavika
function GetPendingLaptops($id)
{
$sql='';
if($id==1)
{
//added by bhavika previous was lpt.dispatch !=1
//chnages into $id=2 in where clause WHERE lpt.status = 'disapprove'
$sql = mysql_query("SELECT DISTINCT usr.user_no, usr.user_firstname, usr.user_lastname, usr.user_designation, lpt.depot_location,lpt.division, lpt.laptopmodel,usr.depot,lpt.dispatch_location,lpt.region, lpt.dispatch_date, lpt.laptop_id,lpt.serial_no,apl.date,lpt.user_name,lpt.date,apl.user_name FROM users AS usr INNER JOIN laptop AS lpt INNER JOIN approved_laptops as apl ON apl.laptop_id=lpt.laptop_id AND usr.user_id=lpt.user_id AND lpt.user_id=apl.user_id WHERE lpt.status = 'approve' AND lpt.assigned =1 AND lpt.recived=0 AND lpt.returned=0 AND lpt.dispatch=0"); 
}
elseif($id==2)
{
$sql = mysql_query("SELECT DISTINCT usr.user_no,usr.user_firstname,usr.user_lastname,usr.user_designation,lpt.depot_location,lpt.division,lpt.laptopmodel,usr.depot,lpt.dispatch_location,lpt.region,lpt.dispatch_date,lpt.laptop_id,lpt.serial_no,dpl.date,lpt.user_name,lpt.date,dpl.user_name FROM users AS usr INNER JOIN laptop AS lpt ON usr.user_id = lpt.user_id INNER JOIN disapproved_laptops as dpl ON lpt.laptop_id=dpl.laptop_id AND lpt.status='disapprove' AND lpt.user_id=dpl.user_id");
}
elseif($id==3)
{
 $sql=mysql_query("SELECT DISTINCT    usr.user_no,usr.user_firstname,usr.user_lastname,usr.user_designation,lpt.depot_location,lpt.division,lpt.dispatch_location,lpt.region,lpt.dispatch_date,lpt.laptop_id,lpt.serial_no,lpt.user_name,lpt.date from users as usr INNER JOIN pending_request as lpt ON usr.user_id = lpt.user_id");
} 
if(mysql_num_rows($sql)>0)//changes made by bhavika
{
$i='1';
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Designation</b></th>
						<th><b>Region</b></th>
						<th><b>Division</b></th>					
						<th><b>From Depot</b></th>
						<th><b>To Depot</b></th>
						<th><b>Laptop Model</b></th>
						<th><b>Serial Number</b></th>';

						//</tr>';
						if($id==1)
						  {
						    $data.='<th><b>Approved By</b></th><th><b>Approve Date</b></th>';
						  }
						else
						  {
						     $data.='<th><b>Request Date</b></th>';
						  }  
	     $data.='<th><b>Requested By</b></th><th><b>Date</b></th></tr>';        					  
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['user_designation'].'</td>
						<td align="center">'.$result['region'].'</td>
						<td align="center">'.$result['division'].'</td>
						<td align="center">'.$result['depot_location'].'</td>					
						<td align="center">'.$result['dispatch_location'].'</td>
						<td align="center">'.$result['laptopmodel'].'</td>
						<td align="center">'.$result['serial_no'].'</td>';
						  if($id==1)
						    {
							   $data.='<td align="center">'.$result['user_name'].'</td><td align="center">'.$result[13].'</td>';
							   
							}
						   else
						     {
							   $data.='<td align="center">'.$result[13].'</td>';
							 }	    
						//<td align="center">'.$result['date'].'</td>
						
						//</tr>';
			   $data.='<td align="center">'.$result['user_name'].'</td><td align="center">'.$result[15]. '</td></tr>';			
			            
						$i++;
						}
$data .= '</table>';
$data.='
<table align="center">
 <tr>
  <td valign="top" colspan="2" align="center">
			<input type="hidden" name="mode" value="pendingLaptop" id="pendingLaptop"/>
			<input type="hidden"  name="pending_value" value="'.$id.'" id="pending_value"/>';
			if($i!=0){
$data.='<input type="submit" value="Save details in excel" class="submit-butt" name="submit" onClick="return downloadPendLaptopReportData()"/>';
			}
			//added change here
$data.=' <input type="button" value="Cancel" class="submit-butt" onClick="javascript:location.href=\'pending_laptop.php\'">
              &nbsp;</td>
          </tr>
 </table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}





function GetAccessoriesStatus()
{
$sql = mysql_query('SELECT usr.user_no,usr.user_firstname,usr.user_lastname,acs.accessories_name,acs.company_name,acs.division,acs.region,acs.depot,acs.dispatch_location,acs.dispatch_date,acs.accessories_id  FROM users as usr INNER JOIN accessories as acs ON  usr.user_id = acs.user_id where acs.dispatch="1" ORDER BY usr.user_no Asc');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="1010"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Accessories Name</b></th>
						<th><b>Data Card</b></th>
						<th><b>Division</b></th>
						<th><b>Region</b></th>
						<th><b>Depot</b></th>
						<th><b>Dispatch Location</b></th>
						<th><b>Dispatch Date</b></th>					
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['accessories_name'].'</td>						
						<td align="center">'.$result['company_name'].'</td>
						<td align="center">'.$result['division'].'</td>						
						<td align="center">'.$result['region'].'</td>						
						<td align="center">'.$result['depot'].'</td>						
						<td align="center">'.$result['dispatch_location'].'</td>
						<td align="center">'.$result['dispatch_date'].'</td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="1010"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}




function GetPendingAccessories()
{
$sql = mysql_query('SELECT usr.user_no,usr.user_firstname,usr.user_lastname,acs.accessories_name,acs.company_name,acs.division,acs.region,acs.depot,acs.dispatch_location,acs.dispatch_date,acs.accessories_id  FROM users as usr INNER JOIN accessories as acs ON  usr.user_id = acs.user_id where acs.status!="approve" and acs.status!="disapprove" ORDER BY usr.user_no Asc');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Accessories Name</b></th>
						<th><b>Data Card</b></th>
						<th><b>Division</b></th>
						<th><b>Region</b></th>
						<th><b>Depot</b></th>
						<th><b>Dispatch Location</b></th>
						<th><b>Dispatch Date</b></th>					
								</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['accessories_name'].'</td>						
						<td align="center">'.$result['company_name'].'</td>
						<td align="center">'.$result['division'].'</td>						
						<td align="center">'.$result['region'].'</td>						
						<td align="center">'.$result['depot'].'</td>						
						<td align="center">'.$result['dispatch_location'].'</td>					
						<td align="center">'.$result['dispatch_date'].'</td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}






function GetQueryEmployeeDetails($id)
{
$sql = mysql_query("SELECT DISTINCT usr.user_no, usr.user_firstname, usr.user_lastname,usr.user_telno,usr.user_address,usr.user_email_address,usr.user_designation,usr.depot  FROM users AS usr WHERE usr.user_no='".trim($id)."'"); 

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980">
                        <tr><th colspan="7"><h2><strong>Personal Details</strong></h2></th></tr>
                        <tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Employee Tel NO</b></th>					
						<th><b>Employee Address</b></th>
						<th><b>Employee Email Address</b></th>					
						<th><b>Employee Designation</b></th>
						<th><b>Employee Depot</b></th>
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['user_telno'].'</td>
						<td align="center">'.$result['user_address'].'</td>					
						<td align="center">'.$result['user_email_address'].'</td>
						<td align="center">'.$result['user_designation'].'</td>
						<td align="center">'.$result['depot'].'</td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><th colspan="6"><h2><strong>Personal Details</strong></h2></th></tr><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}


function GetQueryEmployeeLaptop($id)
{
$sql = mysql_query("SELECT DISTINCT lpt.laptopmodel,lpt.division,lpt.region,lpt.laptop_id,lpt.serial_no FROM users AS usr  JOIN laptop AS lpt ON usr.user_id = lpt.user_id and lpt.dispatch=1 and usr.user_no='".trim($id)."'"); 

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980">
                        <tr><th colspan="6"><h2><strong>Laptop Details</strong></h2></th></tr>
                        <tr>
						<th><b>Laptop Model</b></th>
						<th><b>Serial Number</b></th>
						<th><b>Region</b></th>
						<th><b>Division</b></th>
						<th><b>Laptop Holding Date</b></th>
						<th><b>Box No</b></th>
						
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['laptopmodel'].'</td>
						<td align="center">'.$result['serial_no'].'</td>
						<td align="center">'.$result['region'].'</td>
						<td align="center">'.$result['division'].'</td>
						<td align="center">'.$result['date'].'</td>
						<td align="center">'.GetBoxno($result['serial_no']).'</td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"> <tr><th colspan="6"><h2><strong>Laptop Details</strong></h2></th></tr><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}


function GetQueryEmployeeAccessories($id)
{
$sql = mysql_query("SELECT DISTINCT accd.accessories_name,acs.card_no,acs.company_name,acs.date FROM users AS usr JOIN accessories AS acs  INNER JOIN accessories_data as accd ON usr.user_id = acs.user_id AND accd.accessoriesdata_id=acs.accessories_id AND acs.dispatch = 1 and usr.user_no='".trim($id)."'"); 
if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980">
                        <tr><th colspan="6"><h2><strong>Accessories Details</strong></h2></th></tr>
                        <tr>
						<th><b>Accessories Name</b></th>
						<th><b>Accessories Company</b></th>
						<th><b>Card Number</b></th>
						<th><b>Accessories Holding Date</b></th>
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['accessories_name'].'</td>
						<td align="center">'.$result['company_name'].'</td>
						<td align="center">'.$result['card_no'].'</td>
						<td align="center">'.$result['date'].'</td>
						</tr>';
						}
$data .= '</table>';
$data.='<table align="center">
 <tr>
  <td valign="top" colspan="2" align="center">
			<input type="hidden" name="mode" value="lapQueryReport" id="lapQueryReport"/>
			<input type="hidden" name="empquery" value="'.$id.'" id="empquery"/>';
			$data.='<input type="submit" value="Save details in excel" class="submit-butt" name="submit" onClick="return downloadEmpQueryReportData()"/>';
			$data.=' <input type="button" value="Cancel" class="submit-butt" onClick="javascript:location.href=\'query_employee.php\'">
			   &nbsp;</td>
          </tr>
 </table>';
}
else
{
$data ='<table border="0" class="grid" width="980"> <tr><th colspan="6"><h2><strong>Accessories Details</strong></h2></th></tr><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}


function GetQueryLPrevEmployeeDetails($id)
{
/*$sqlsn = mysql_query("SELECT *  FROM laptop_details WHERE serial_no='".trim($id)."'"); 
$resultsn = mysql_fetch_row($sqlsn);
$laptop_name = $resultsn[5];*/

$sql = mysql_query("SELECT DISTINCT usr.user_no, usr.user_firstname, usr.user_lastname, usr.user_telno, usr.user_address, usr.user_email_address, usr.user_designation, lpt.laptopmodel, lpt.dispatch_date, lpt.laptop_id, lpt.serial_no FROM users AS usr JOIN laptop AS lpt INNER JOIN laptop_details AS lpd ON usr.user_id = lpt.user_id AND lpt.laptop_id = lpd.laptop_id AND lpd.status = '0' AND lpt.dispatch =1 AND lpt.serial_no = '".trim($id)."' AND lpt.returned = '1'"); 

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980">
                        <tr><th colspan="6"><h2><strong>Laptop Holders</strong></h2></th></tr>
                        <tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Employee Tel NO</b></th>					
						<th><b>Employee Address</b></th>
						<th><b>Employee Email Address</b></th>					
						<th><b>Employee Designation</b></th>
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['user_telno'].'</td>
						<td align="center">'.$result['user_address'].'</td>					
						<td align="center">'.$result['user_email_address'].'</td>
						<td align="center">'.$result['user_designation'].'</td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td colspan="6">no records</td></tr><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}


function GetQueryLPEmployeeDetails($id)
{
/*$sqlsn = mysql_query("SELECT *  FROM laptop_details WHERE serial_no='".trim($id)."'"); 
$resultsn = mysql_fetch_row($sqlsn);
$laptop_name = $resultsn[5];*/

$sql = mysql_query("SELECT DISTINCT usr.user_no, usr.user_firstname, usr.user_lastname, usr.user_telno, usr.user_address, usr.user_email_address, usr.user_designation, lpt.laptopmodel, lpt.dispatch_date, lpt.laptop_id, lpt.serial_no FROM users AS usr JOIN laptop AS lpt INNER JOIN laptop_details AS lpd ON usr.user_id = lpt.user_id AND lpt.laptop_id = lpd.laptop_id AND lpd.status = '0' AND lpt.dispatch =1 AND lpt.serial_no = '".trim($id)."' AND lpt.returned = '0'"); 

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980">
                        <tr><th colspan="6"><h2><strong>Laptop Holders</strong></h2></th></tr>
                        <tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Employee Tel NO</b></th>					
						<th><b>Employee Address</b></th>
						<th><b>Employee Email Address</b></th>					
						<th><b>Employee Designation</b></th>
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['user_telno'].'</td>
						<td align="center">'.$result['user_address'].'</td>					
						<td align="center">'.$result['user_email_address'].'</td>
						<td align="center">'.$result['user_designation'].'</td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td colspan="6">no records</td></tr><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}


function GetQueryLPEmployeeLaptop($id)
{
$sqlsn = mysql_query("SELECT *  FROM laptop_details WHERE serial_no='".trim($id)."'"); 
if(mysql_num_rows($sqlsn)>0)
{
$data .='<table border="0" class="grid" width="980">
                        <tr><th colspan="6"><h2><strong>Laptop Details</strong></h2></th></tr>
                        <tr>
						<th><b>Serial No</b></th>
						<th><b>Laptop Model</b></th>
						<th><b>Box No</b></th>
    					<th><b>Manufactured Date</b></th>
					</tr>';
while($resultsn = mysql_fetch_array($sqlsn)){

$data .= '<tr class="odd">  
                        <td align="center">'.$resultsn['serial_no'].'</td>
						<td align="center">'.$resultsn['laptop_name']. '-' .$resultsn['laptop_model'].'</td>
						<td align="center">'.$resultsn['box_no'].'</td>
						<td align="center">'.$resultsn['manufactured_date'].'</td>
				</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"> <tr><th colspan="6"><h2><strong>Laptop Details</strong></h2></th></tr><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}


function GetQueryLPEmployeeAccessories($id)
{
/*$sqlsn = mysql_query("SELECT *  FROM laptop_details WHERE serial_no='".trim($id)."'"); 
$resultsn = mysql_fetch_row($sqlsn);
$laptop_name =$resultsn[5];*/


$sql = mysql_query("SELECT DISTINCT usr.user_no, usr.user_firstname, usr.user_lastname,usr.user_telno,usr.user_address,usr.user_email_address,usr.user_designation, lpt.laptopmodel, lpt.dispatch_date, lpt.laptop_id, acs.accessories_name,acs.company_name,acs.card_no FROM users AS usr JOIN laptop AS lpt JOIN accessories AS acs ON usr.user_id = lpt.user_id  AND usr.user_id = acs.user_id WHERE acs.dispatch = 1 and acs.returned='0' and lpt.serial_no='".trim($id)."'"); 

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980">
                        <tr><th colspan="6"><h2><strong>Accessories Details</strong></h2></th></tr>
                        <tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Accessories Name</b></th>
						<th><b>Accessories Company</b></th>
						<th><b>Card Number</b></th>
						<th><b>Accessories Holding Date</b></th>
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">						
                        <td align="center">'.$result['user_no'].'</td>
		        		<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['accessories_name'].'</td>
						<td align="center">'.$result['company_name'].'</td>
						<td align="center">'.$result['card_no'].'</td>
						<td align="center">'.$result['dispatch_date'].'</td>
						</tr>';
						}
$data .= '</table>';
$data.='<table align="center">
 <tr>
  <td valign="top" colspan="2" align="center">
			<input type="hidden" name="mode" value="queryonlap" id="queryonlap"/>
			<input type="hidden" name="model" value="'.$laptop_name.'" id="model"/>';
			$data.='<input type="submit" value="Save details in excel" class="submit-butt" name="submit" onClick="return downloadaccempSerialdeliReportData()"/>';
			$data.='<input type="button" value="Cancel" class="submit-butt" onClick="javascript:location.href=\'query_laptop.php\'">
              &nbsp;</td>
          </tr>
 </table>';
}
else
{
$data ='<table border="0" class="grid" width="980"> <tr><th colspan="6"><h2><strong>Accessories Details</strong></h2></th></tr><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}




function GetLaptopList()
{
$sql = mysql_query("SELECT * FROM laptop WHERE assigned = 1"); 

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980">
                        <tr>
						<th><b>Laptop Model</b></th>
						<th><b>Serial No</b></th>
						<th><b>Box No</b></th>
						<th><b>Division</b></th>
						<th><b>Region</b></th>
						<th><b>Depot</b></th>
						<th><b>Dispatch Location</b></th>
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">					
						<td align="center">'.$result['laptopmodel'].'</td>
						<td align="center">'.$result['serial_no'].'</td>
						<td align="center">'.GetBoxno($result['serial_no']).'</td>
                        <td align="center">'.$result['division'].'</td>
						<td align="center">'.$result['region'].'</td>
						<td align="center">'.$result['depot'].'</td>
						<td align="center">'.$result['dispatch_location'].'</td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}






function GetLaptopStatus($id)
{
$sql='';
if($id=="1")
{
$sql = mysql_query("SELECT usr.user_no, usr.user_firstname, usr.user_lastname, usr.user_designation, usr.user_doj, usr.depot, lpt.division, lpt.region, lpt.laptopmodel, lpt.depot_location, lpt.dispatch_location, lpt.serial_no, lpd.box_no, lpd.laptop_type, lpt.user_name, lpt.date,usr.user_id
FROM users AS usr INNER JOIN laptop AS lpt INNER JOIN laptop_details AS lpd ON usr.user_id = lpt.user_id AND lpt.laptop_id = lpd.laptop_id and lpd.status='0' and lpd.laptop_type!='L' and lpd.laptop_type!='X' and lpd.laptop_type!='R' and lpd.laptop_type!='D' AND lpt.returned='0'"); 
}
elseif($id=="2")
{
 $sql = mysql_query("SELECT   usr.user_no,usr.user_firstname,usr.user_lastname,usr.user_designation,usr.user_doj,usr.depot,lpt.division,lpt.region,lpt.laptopmodel,lpt.depot_location,lpt.dispatch_location,lpt.serial_no,lpd.box_no,lpd.laptop_type,lpt.user_name,lpt.date,usr.user_id FROM  users as usr INNER JOIN  laptop as lpt INNER JOIN laptop_details as lpd ON usr.user_id=lpt.user_id AND lpt.laptop_id=lpd.laptop_id AND laptop_type='R'"); 
}
elseif($id=="3")
{
   $sql=mysql_query("SELECT DISTINCT    usr.user_no,usr.user_firstname,usr.user_lastname,usr.user_id,usr.user_designation,usr.user_doj,usr.depot,lpt.depot_location,lpt.division,lpt.dispatch_location,lpt.region,lpt.dispatch_date,lpt.laptop_id,lpt.serial_no,lpt.user_name,lpt.date from users as usr INNER JOIN pending_request as lpt ON usr.user_id = lpt.user_id");
}



if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980">
                        <tr>
						<th><b>User No</b></th>
						<th><b>User Name</b></th>
						<th><b>User Designation</b></th>
						<th><b>Laptop Model</b></th>
						<th><b>Serial No</b></th>
						<th><b>Box No</b></th>
						<th><b>Data Card Number</b></th>
						<th><b>Division</b></th>
						<th><b>Region</b></th>
						<th><b>Depot</b></th>
						<th><b>Dispatch Location</b></th>
						<th><b>Depot Location</b></th>
						<th><b>Date of Joinning</b></th>
						<th><b>Requested By</b></th>
						<th><b>Requested Date</b></th>
						<th><b>Laptop Type</b></th>
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
                        <td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].' '. $result['user_lastname'].'</td>
						<td align="center">'.$result['user_designation'].'</td>
						<td align="center">'.$result['laptopmodel'].'</td>
						<td align="center">'.$result['serial_no'].'</td>
						<td align="center">'.$result['box_no'].'</td>';
						$sql26=mysql_query("select card_no from accessories where accessories_id='2' AND user_id='".$result['user_id']."'" );
						$result26=mysql_fetch_row($sql26);
						$data.='<td align="center">'.$result26[0].'</td>
                        <td align="center">'.$result['division'].'</td>
						<td align="center">'.$result['region'].'</td>
						<td align="center">'.$result['depot'].'</td>
						<td align="center">'.$result['dispatch_location'].'</td>
						<td align="center">'.$result['depot_location'].'</td>
						<td align="center">'.$result['user_doj'].'</td>
						<td align="center">'.$result['user_name'].'</td>
						<td align="center">'.$result['date'].'</td>
						<td align="center">'.$result['laptop_type'].'</td>';
						}
$data .= '</table>';
$data.='<table align="center">
 <tr>
  <td valign="top" colspan="2" align="center">
			<input type="hidden" name="mode" value="laptopstatus" id="laptopstatus"/>
			<input type="hidden" name="status" value="'.$id.'" id="status"/>';
			$data.='<input type="submit" value="Save details in excel" class="submit-butt" name="submit" onClick="return downloadLaptopStatusReportData()"/>';
			$data.='<input type="button" value="Cancel" class="submit-butt" onClick="javascript:location.href=\'laptop_status.php\'">
              &nbsp;</td>
          </tr>
 </table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}






function GetReturnLaptopRecords($date1,$date2)
{
$sql = mysql_query("SELECT DISTINCT usr.user_no,usr.user_firstname,usr.user_lastname,lpt.division,lpt.laptopmodel,lpt.region,lpt.depot,lpt.dispatch_location,lpt.dispatch_date,lpt.laptop_id,lpt.serial_no FROM users as usr INNER JOIN  laptop as lpt ON  usr.user_id = lpt.user_id INNER JOIN return_laptop as rl ON rl.laptop_id = lpt.laptop_id where rl.Date BETWEEN '".trim($date1)."' AND '".trim($date2)."' "); 

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="1050" cellpadding="4"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Division</b></th>
						<th><b>Model No</b></th>
						<th><b>Serial No</b></th>
						<th><b>Box No</b></th>
						<th><b>Region</b></th>
						<th><b>Depot</b></th>
						<th><b>Dispatch Location</b></th>
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['division'].'</td>
						<td align="center">'.$result['laptopmodel'].'</td>
						<td align="center">'.$result['serial_no'].'</td>
						<td align="center">'.GetBoxno($result['serial_no']).'</td>
						<td align="center">'.$result['region'].'</td>
						<td align="center">'.$result['depot'].'</td>
						<td align="center">'.$result['dispatch_location'].'</td>					
							</tr>						
					';
}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="1000"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}



function GetLaptopRecords($id)
{
if($id == '1')
{
$remark = 'Return';
}
elseif($id == '2')
{
$remark = 'Home';
}
elseif($id == '3')
{
$remark = 'Lost';
}
elseif($id == '4')
{
$remark = 'Damage';
}


$sql = mysql_query("SELECT DISTINCT usr.user_no,usr.user_firstname,usr.user_lastname,lpt.division,lpt.laptopmodel,lpt.region,lpt.depot,lpt.dispatch_location,lpt.dispatch_date,lpt.laptop_id,lpt.serial_no FROM users as usr INNER JOIN  laptop as lpt ON  usr.user_id = lpt.user_id INNER JOIN return_laptop as rl ON rl.laptop_id = lpt.laptop_id where `remarks`='".$remark."'"); 

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="1050" cellpadding="4"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Division</b></th>
						<th><b>Model No</b></th>
						<th><b>Serial No</b></th>
						<th><b>Box No</b></th>
						<th><b>Region</b></th>
						<th><b>Depot</b></th>
						<th><b>Dispatch Location</b></th>
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['division'].'</td>
						<td align="center">'.$result['laptopmodel'].'</td>
						<td align="center">'.$result['serial_no'].'</td>
						<td align="center">'.GetBoxno($result['serial_no']).'</td>
						<td align="center">'.$result['region'].'</td>
						<td align="center">'.$result['depot'].'</td>
						<td align="center">'.$result['dispatch_location'].'</td>					
							</tr>						
					';
}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="1000"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}




function GetBoxno($value)
{
$sql = mysql_query('SELECT box_no FROM `laptop_details` where serial_no ="'.$value.'"');
while($result = mysql_fetch_row($sql))
{
$data .= $result[0];
}
return $data;
}

function GetLaptopDispatchReport($value1,$value2)
{
$date1 = date('d-m-y', strtotime($value1)); 
$date2 = date('d-m-y', strtotime($value2)); 

//echo $date1;
//echo $date2;

$sql = mysql_query("SELECT  usr.user_no,usr.user_firstname,usr.user_id,usr.user_lastname,usr.user_designation,usr.depot,lpt.region,lpt.division,lpt.laptopmodel,lpt.serial_no,lpt.depot_location,lpt.dispatch_location,dsl.date,lpt.user_name,lpt.date,lpt.laptop_id FROM users as usr INNER JOIN  laptop as lpt INNER JOIN  assigned_laptops as dsl ON usr.user_id = lpt.user_id and dsl.laptop_id = lpt.laptop_id and dsl.user_id = lpt.user_id where dsl.date >='".$date1."'AND dsl.date <='".$date2."'");

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Employee Designation</b></th>
						<th><b>Division</b></th>
						<th><b>Region</b></th>
						<th><b>Reort to Depot</b></th>
						<th><b>Laptop Model</b></th>
						<th><b>Laptop Serial Number</b></th>
						<th><b>Data Card Number</b></th>
						<th><b>From Depot</b></th>
						<th><b>To Depot</b></th>
						<th><b>Dispatch Date</b></th>
						<th><b>Box No</b></th>
						<th><b>Requested By</b></th>
						<th><b>Date</b></th>
						</tr>';
						$i=0;
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['user_designation'].'</td>						
						<td align="center">'.$result['division'].'</td>						
						<td align="center">'.$result['region'].'</td>
						<td align="center">'.$result['depot'].'</td>						
						<td align="center">'.$result['laptopmodel'].'</td>
						<td align="center">'.$result['serial_no'].'</td>';
						$sql25=mysql_query("select card_no from accessories where accessories_id='2' AND user_id='".$result['user_id']."'");
						$result25=mysql_fetch_row($sql25);
						$data.='<td align="center">'.$result25[0].'</td>						
						<td align="center">'.$result['depot_location'].'</td>					
						<td align="center">'.$result['dispatch_location'].'</td>
						<td align="center">'.$result[11].'</td>';
						$sql2=mysql_query("select box_no from laptop_details where laptop_id='".$result['laptop_id']."'");
			            $result25=mysql_fetch_row($sql2);
						$data .='<td align="center">'.$result25[0].'</td>
						<td align="center">'.$result['user_name'].'</td>
						<td align="center">'.$result[13].'</td>
						</tr>';
						}
						$i++;
$data .= '</table>';
$data.='
<table align="center">
 <tr>
  <td valign="top" colspan="2" align="center">
			<input type="hidden" name="mode" value="lapdispatched" id="lapdispatched"/>
			<input type="hidden" name="del_sdate" value="'.$date1.'" id="del_sdate"/>
			<input type="hidden" name="del_edate" value="'.$date2.'" id="del_edate"/>';
			if($i!=0){
$data.='<input type="submit" value="Save details in excel" class="submit-butt" name="submit" onClick="return downloadLaptopDispatchReportData(this.frm)"/>';
			}
			//added change here
$data.=' <input type="button" value="Cancel" class="submit-butt" onClick="javascript:location.href=\'laptop_delievered.php\'">
              &nbsp;</td>
          </tr>
 </table>';

}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}
//done by bhavika
function GetLaptopDelieveredReport($value1,$value2)
{
 $i=1;
 $date1 = date('d-m-y', strtotime($value1)); 
 $date2 = date('d-m-y', strtotime($value2)); 
 $sql = mysql_query("SELECT  usr.user_no,usr.user_firstname,usr.user_lastname,usr.user_designation,usr.depot,lpt.region,lpt.division,lpt.laptopmodel,lpt.serial_no,lpt.depot_location,lpt.dispatch_location,dsl.date,dsl.receipt,lpt.user_name,lpt.date,lpt.laptop_id FROM users as usr INNER JOIN  laptop as lpt INNER JOIN  dispatched_laptop as dsl ON  usr.user_id = lpt.user_id and dsl.laptop_id = lpt.laptop_id and dsl.user_id = lpt.user_id where dsl.date >='".$date1."'AND dsl.date <='".$date2."'");

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Employee Designation</b></th>
						<th><b>Report to Depot</b></th>
						<th><b>Region</b></th>
						<th><b>Division</b></th>
						<th><b>Laptop Model</b></th>
						<th><b>Laptop Serial Number</b></th>
						<th><b>From Depot</b></th>
						<th><b>To Depot</b></th>
						<th><b>Delivery Date</b></th>
						<th><b>Requested By</b></th>
                        <th><b>Requested Date</b></th>
						<th><b>Box No</b></th> 
						<th><b>Reciept</b></th>
						</tr>';
								
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['user_designation'].'</td>
						<td align="center">'.$result['depot'].'</td>						
						<td align="center">'.$result['region'].'</td>
						<td align="center">'.$result['division'].'</td>							
						<td align="center">'.$result['laptopmodel'].'</td>
						<td align="center">'.$result['serial_no'].'</td>						
						<td align="center">'.$result['depot_location'].'</td>					
						<td align="center">'.$result['dispatch_location'].'</td>
						<td align="center">'.$result[11].'</td>
						<td align="center">'.$result['user_name'].'</td>
						<td align="center">'.$result[14].'</td>';
						$sql2=mysql_query("select box_no from laptop_details where laptop_id='".$result['laptop_id']."'");
			            $result25=mysql_fetch_row($sql2);
			            $data .='<td align="center">'.$result25[0].'</td>
						<td align="center"><a href="download_reciept.php?receipt='.$result['receipt'].'">'.$result['receipt'].'</a></td>
						</tr>';
						}
						$i++;
$data .= '</table>';
$data.='
<table align="center">
 <tr>
  <td valign="top" colspan="2" align="center">
			<input type="hidden" name="mode" value="lapdelievered" id="lapdelievered"/>
			<input type="hidden" name="del_sdate" value="'.$date1.'" id="del_sdate"/>
			<input type="hidden" name="del_edate" value="'.$date2.'" id="del_edate"/>';
			if($i!=0){
$data.='<input type="submit" value="Save details in excel" class="submit-butt" name="submit" onClick="return downloadLaptopdeliReportData(this.frm)"/>';
			}
			//added change here
$data.=' <input type="button" value="Cancel" class="submit-butt" onClick="javascript:location.href=\'laptop_delievered.php\'">
              &nbsp;</td>
          </tr>
 </table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data; 
}
//done by bhavika
function GetLapUndelieveredReport()
{
//$date1 = date('d-m-y', strtotime($value1)); 
//$date2 = date('d-m-y', strtotime($value2)); 
 
$sql = mysql_query("SELECT lpt.region, lpt.division, lpt.laptopmodel, lpt.serial_no, lpt.depot_location, lpt.dispatch_location, usr.user_no, usr.user_firstname, usr.user_lastname, usr.user_designation, lpt.user_name, lpt.date, lpt.laptop_id FROM users AS usr INNER JOIN laptop AS lpt ON lpt.user_id = usr.user_id AND lpt.assigned = '1' AND lpt.recived = '1' AND lpt.dispatch = '0'");

if(mysql_num_rows($sql)>0)
{
 $i=1;
 $data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Employee Designation</b></th>
						<th><b>Division</b></th>
						<th><b>Region</b></th>
						<th><b>Laptop Model</b></th>
						<th><b>Laptop Serial Number</b></th>
						<th><b>Box No</b></th>
						<th><b>Depot Location</b></th>
						<th><b>Dispatch Location</b></th>
						<th><b>Date</b></th>
						<th><b>Requested By</b></th>
						<th><b>Date</b></th>
											
								</tr>';
while($result = mysql_fetch_array($sql)){
$i=1;
$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['user_designation'].'</td>						
						<td align="center">'.$result['division'].'</td>						
						<td align="center">'.$result['region'].'</td>						
						<td align="center">'.$result['laptopmodel'].'</td>
						<td align="center">'.$result['serial_no'].'</td>';
						$sql2=mysql_query("select box_no from laptop_details where laptop_id='".$result['laptop_id']."'");
			            $result25=mysql_fetch_row($sql2);
			            $data.='<td align="center">'.$result25[0].'</td>
						<td align="center">'.$result['depot_location'].'</td>					
						<td align="center">'.$result['dispatch_location'].'</td>';
						$sql26=mysql_query("select date from received_laptop where laptop_id='".$result['laptop_id']."'");
			            $result26=mysql_fetch_row($sql26);
						//<td align="center">'.$result[0].'</td>
						$data.='<td align="center">'.$result26[0].'</td>
						<td align="center">'.$result['user_name'].'</td>
						<td align="center">'.$result['date'].'</td>
						</tr>';
						}
						$i++;
$data .= '</table>';
$data.='
<table align="center">
 <tr>
  <td valign="top" colspan="2" align="center">
			<input type="hidden" name="mode" value="lapundelievered" id="lapundelievered"/>';
			if($i!=0){
$data.='<input type="submit" value="Save details in excel" class="submit-butt" name="submit" onClick="return downloadLaptopUndeliReportData()"/>';
			}
			//added change here
$data.=' <input type="button" value="Cancel" class="submit-butt" onClick="javascript:location.href=\'laptop_undelievered.php\'">
              &nbsp;</td>
          </tr>
 </table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
 return $data;	  
}

function GetPendingAccessories1($id)
{
  
  if($id==1)
   {
      $sql=mysql_query("select usr.user_no,usr.user_firstname,acc.company_name,usr.user_lastname,usr.user_designation,acc.division,acc.region,acc.depot_location,acc.dispatch_location,acc.card_no,appacc.date,acc.user_name,acc.date from users as usr INNER JOIN accessories AS acc ON acc.user_id=usr.user_id INNER JOIN approved_accessories AS appacc ON appacc.accessories_id=acc.accessories_id AND appacc.user_id=acc.user_id where acc.status='approve' and acc.assigned=1 AND acc.received=0 AND acc.returned=0 AND acc.dispatch=0");
	 
   }
   else if($id==2)
    {
	  $sql = mysql_query("SELECT * FROM users AS usr INNER JOIN accessories AS acc INNER JOIN disapproved_accessories  as dacc ON acc.accessories_id=dacc.accessories_id AND usr.user_id=dacc.user_id AND usr.user_id=acc.user_id AND acc.status='disapprove'");
	  
	}
$i='1';
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Designation</b></th>
						<th><b>Region</b></th>
						<th><b>Division</b></th>					
						<th><b>From Depot</b></th>
						<th><b>To Depot</b></th>
						<th><b>Data Card Company</b></th>
						<th><b>Card Number</b></th>';
						//</tr>';
						if($id==1)
						  {
						    $data.='<th><b>Approve Date</b></th>';
						  }
						else
						  {
						     $data.='<th><b>Request Date</b></th>';
						  }  
	     $data.='<th><b>Requested By</b></th><th><b>Date</b></th></tr>';
if(mysql_num_rows($sql))
 {        					  
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['user_designation'].'</td>
						<td align="center">'.$result['region'].'</td>
						<td align="center">'.$result['division'].'</td>
						<td align="center">'.$result['depot_location'].'</td>					
						<td align="center">'.$result['dispatch_location'].'</td>
						<td align="center">'.$result['company_name'].'</td>
						<td align="center">'.$result['card_no'].'</td>';
						  if($id==1)
						    {
							  $data.='<td align="center">'.$result['date'].'</td>';
							}
						   else
						     {
							  $data.='<td align="center">'.$result['date'].'</td>';
							 }	    
						//<td align="center">'.$result['date'].'</td>
						
						//</tr>';
			   $data.='<td align="center">'.$result['user_name'].'</td><td align="center">'.$result['date'].'</td></tr>';			
						$i++;
						}
$data .= '</table>';
$data.='
<table align="center">
 <tr>
  <td valign="top" colspan="2" align="center">
			<input type="hidden" name="mode" value="pendingAccessories" id="pendingAccessories"/>
			<input type="hidden"  name="pending_accvalue" value="'.$id.'" id="pending_accvalue"/>';
			if($i!=0){
$data.='<input type="submit" value="Save details in excel" class="submit-butt" name="submit" onClick="return downloadPendAccessoriesReportData()"/>';
			}
			//added change here
$data.=' <input type="button" value="Cancel" class="submit-butt" onClick="javascript:location.href=\'pending_laptop.php\'">
              &nbsp;</td>
          </tr>
 </table>';
 }
 else
 {
   $data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
 }
 return $data;
}

function GetAccessoriDispatchReport($value1,$value2)
{
$date1 = date('d-m-y', strtotime($value1)); 
$date2 = date('d-m-y', strtotime($value2)); 

$sql = mysql_query("SELECT  usr.user_no,usr.user_firstname,usr.user_lastname,usr.user_designation,usr.depot,acc.division,acc.region,acc.accessories_name,acc.card_no,acc.depot_location,acc.dispatch_location,asa.date,acc.user_name,acc.date  FROM users as usr INNER JOIN  accessories  as acc ON  usr.user_id = acc.user_id INNER JOIN  assigned_accessories  as asa ON asa.accessories_id = acc.accessories_id AND asa.user_id=acc.user_id where asa.Date>='".$date1."' AND asa.Date<='".$date2 ."'");

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Employee Designation</b></th>
						<th><b>Division</b></th>
						<th><b>Region</b></th>
						<th><b>Accessories Name</b></th>
						<th><b>Card Number</b></th>
						<th><b>From Depot</b></th>
						<th><b>To Depot</b></th>
						<th><b>Dispatch Date</b></th>
						<th><b>Requested By</b></th>
						<th><b>Date</b></th>
						</tr>';
						$i=0;
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['user_designation'].'</td>						
						<td align="center">'.$result['division'].'</td>						
						<td align="center">'.$result['region'].'</td>
						<td align="center">'.$result['accessories_name'].'</td>
						<td align="center">'.$result['card_no'].'</td>						
						<td align="center">'.$result['depot_location'].'</td>					
						<td align="center">'.$result['dispatch_location'].'</td>
						<td align="center">'.$result[11].'</td>
						<td align="center">'.$result['user_name'].'</td>
						<td align="center">'.$result[13].'</td>
						</tr>';
						}
						$i++;
$data .= '</table>';
$data.='
<table align="center">
 <tr>
  <td valign="top" colspan="2" align="center">
			<input type="hidden" name="mode" value="accdispatched" id="accdispatched"/>
			<input type="hidden" name="del_sdate" value="'.$date1.'" id="del_sdate"/>
			<input type="hidden" name="del_edate" value="'.$date2.'" id="del_edate"/>';
			if($i!=0){
$data.='<input type="submit" value="Save details in excel" class="submit-butt" name="submit" onClick="return downloadAccesDispatchReportData(this.frm)"/>';
			}
			//added change here
$data.=' <input type="button" value="Cancel" class="submit-butt" onClick="javascript:location.href=\'laptop_delievered.php\'">
              &nbsp;</td>
          </tr>
 </table>';

}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}

function GetAccessoriDelieveredReport($value1,$value2)
{
$date1 = date('d-m-y', strtotime($value1)); 
$date2 = date('d-m-y', strtotime($value2)); 
$sql = mysql_query("SELECT  usr.user_no,usr.user_firstname,usr.user_lastname,usr.user_designation,usr.depot,acc.region,acc.division,acc.accessories_name,acc.card_no,acc.depot_location,acc.dispatch_location,dsl.date,dsl.receipt,acc.user_name,acc.date FROM users as usr INNER JOIN  accessories  as acc  INNER JOIN  dispatched_accessories as dsl ON usr.user_id = acc.user_id AND dsl.accessories_id = acc.accessories_id AND dsl.user_id=acc.user_id where dsl.date >='".$date1."'AND dsl.date <='".$date2."'");

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Employee Designation</b></th>
						<th><b>Report to Depot</b></th>
						<th><b>Region</b></th>
						<th><b>Division</b></th>
						<th><b>Accessories Name</b></th>
						<th><b>Card Number</b></th>
						<th><b>From Depot</b></th>
						<th><b>To Depot</b></th>
						<th><b>Delivery Date</b></th>
						<th><b>Requested By</b></th>
						<th><b>Date</b></th>
						<th><b>Reciept</b></th>
									
								</tr>';
								$i=1;
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['user_designation'].'</td>
						<td align="center">'.$result['depot'].'</td>						
						<td align="center">'.$result['region'].'</td>
						<td align="center">'.$result['division'].'</td>							
						<td align="center">'.$result['accessories_name'].'</td>
						<td align="center">'.$result['card_no'].'</td>						
						<td align="center">'.$result['depot_location'].'</td>					
						<td align="center">'.$result['dispatch_location'].'</td>
						<td align="center">'.$result[11].'</td>
						<td align="center">'.$result['user_name'].'</td>
						<td align="center">'.$result[14].'</td>
						<td align="center"><a href="download_receiptacc.php?receipt='.$result['receipt'].'">'.$result['receipt'].'</a></td>
						</tr>';
						}
						$i++;
$data .= '</table>';
$data.='
<table align="center">
 <tr>
  <td valign="top" colspan="2" align="center">
			<input type="hidden" name="mode" value="accdelievered" id="accdelievered"/>
			<input type="hidden" name="sdate" value="'.$date1.'" id="sdate"/>
			<input type="hidden" name="edate" value="'.$date2.'" id="edate"/>';
			if($i!=0){
$data.='<input type="submit" value="Save details in excel" class="submit-butt" name="submit" onClick="return downloadaccdeliReportData()"/>';
			}
			//added change here
$data.=' <input type="button" value="Cancel" class="submit-butt" onClick="javascript:location.href=\'laptop_delievered.php\'">
              &nbsp;</td>
          </tr>
 </table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data; 
}

function GetAccessoriesCount($id1,$id2)
{
   $value1=date('d-m-y', strtotime($id1));
   $value2=date('d-m-y', strtotime($id2)); 
   $sql=mysql_query("SELECT count( accessories_id ), accessories_name FROM assigned_accessories, accessories_data WHERE accessories_id = accessoriesdata_id AND date >= '".$value1."'AND date <='".$value2."'GROUP BY accessories_id");
   if(mysql_num_rows($sql)>0)
   {
     $i=1;
         $data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Accessories Name</b></th>
						<th><b>Total Number Of Accessories</b></th>
						
												
								</tr>';
while($result = mysql_fetch_array($sql)){
$i=1;
$data .= '<tr class="odd">
						<td align="center">'.$result['accessories_name'].'</td>
						<td align="center">'.$result['count( accessories_id )'].'</td>
		  </tr>';
						}
						$i++;
$data .= '</table>';
$data.='
<table align="center">
 <tr>
  <td valign="top" colspan="2" align="center">
			<input type="hidden" name="mode" value="accreport" id="accreport"/>
			<input type="hidden" name="sdate" value="'.$value1.'" id="sdate"/>
			<input type="hidden" name="edate" value="'.$value2.'" id="edate"/>'; 
			if($i!=0){
$data.='<input type="submit" value="Save details in excel" class="submit-butt" name="submit" onClick="return downloadAccReportData()"/>';
			}
			//added change here
$data.=' <input type="button" value="Cancel" class="submit-butt" onClick="javascript:location.href=\'accessories_report.php\'">
              &nbsp;</td>
          </tr>
 </table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
 return $data;	  
}

function GetAccessoriesStock($id1,$id2)
{
   $value1=date('d-m-y', strtotime($id1));
   $value2=date('d-m-y', strtotime($id2)); 
   $sql=mysql_query("SELECT ad.accessories_name, asd.quantity, asd.date,asd.depot_location FROM accessories_stock_details AS asd INNER JOIN accessories_data AS ad ON   asd.accessories_id = ad.accessoriesdata_id WHERE asd.date >='".$value1."'AND asd.date <='".$value2."'");
   if(mysql_num_rows($sql)>0)
   {
     $i=1;
         $data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Accessories Name</b></th>
						<th><b>Quantity</b></th>
						<th><b>Depot</b></th>
						<th><b>Date</b></th>
				 </tr>';
				 
while($result = mysql_fetch_array($sql)){
$i=1;
$data .= '<tr class="odd">
						<td align="center">'.$result['accessories_name'].'</td>
						<td align="center">'.$result['quantity'].'</td>
						<td align="center">'.$result['depot_location'].'</td>
						<td align="center">'.$result['date'].'</td>
		  </tr>';
						}
						$i++;
$data .= '</table>';
$data.='
<table align="center">
 <tr>
  <td valign="top" colspan="2" align="center">
			<input type="hidden" name="mode" value="accStockreport" id="accStockreport"/>
			<input type="hidden" name="sdate" value="'.$value1.'" id="sdate"/>
			<input type="hidden" name="edate" value="'.$value2.'" id="edate"/>'; 
			if($i!=0){
$data.='<input type="submit" value="Save details in excel" class="submit-butt" name="submit" onClick="return downloadAccStockReportData()"/>';
			}
			//added change here
$data.=' <input type="button" value="Cancel" class="submit-butt" onClick="javascript:location.href=\'accessories_stock_report.php\'">
              &nbsp;</td>
          </tr>
 </table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
 return $data;	  
   
}

function GetAccessoriesDailyStockReportData()
{
  $today=date("d-m-y");
  $sql=mysql_query("SELECT ad.accessories_name, asd.quantity, asd.depot_location FROM accessories_stock_details AS asd INNER JOIN accessories_data AS ad ON asd.accessories_id = ad.accessoriesdata_id WHERE asd.date = '".$today."'");
   if(mysql_num_rows($sql)>0)
   {
     $i=1;
         $data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Accessories Name</b></th>
						<th><b>Quantity</b></th>
						<th><b>Depot</b></th>
						
						
												
								</tr>';
while($result = mysql_fetch_array($sql)){
$i=1;
$data .= '<tr class="odd">
						<td align="center">'.$result['accessories_name'].'</td>
						<td align="center">'.$result['quantity'].'</td>
						<td align="center">'.$result['depot_location'].'</td>
						</tr>';
						}
						$i++;
$data .= '</table>';
$data.='
<table align="center">
 <tr>
  <td valign="top" colspan="2" align="center">
			<input type="hidden" name="mode" value="accStockDailyReport" id="accStockDailyReport"/>
			<input type="hidden" name="tdate" value="'.$today.'" id="tdate"/>';
			if($i!=0){
$data.='<input type="submit" value="Save details in excel" class="submit-butt" name="submit" onClick="return downloadAccStockDailyReportData()"/>';
			}
			//added change here
$data.=' 
          </tr>
 </table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
 return $data;	  
  
}

function  GetLaptopDepot($id)
{
    $sql="";
    if($id=="1")
     {
	  $sql=mysql_query("Select laptop_name ,laptop_model,box_no,serial_no,depot_location,laptop_type from laptop_details where status='1' and laptop_type='O' order by depot_location ASC");
	 }
	 elseif($id=="2")
	 {
	  $sql=mysql_query("Select laptop_name ,laptop_model,box_no,serial_no,depot_location,laptop_type from laptop_details where status='1' and laptop_type='S' order by depot_location ASC");
	 }
	 elseif($id=="3")
	 {
	  $sql=mysql_query("Select laptop_name ,laptop_model,box_no,serial_no,depot_location,laptop_type from laptop_details where laptop_type='X' order by depot_location ASC"); 
	 }
	 elseif($id=="4")
	 {
	    $sql=mysql_query("Select laptop_name ,laptop_model,box_no,serial_no,depot_location,laptop_type from laptop_details where status='3' order by depot_location ASC");
	 }
	 elseif($id=="5")
	 {
	    $sql=mysql_query("Select laptop_name ,laptop_model,box_no,serial_no,depot_location,laptop_type from laptop_details where status='4' order by depot_location ASC");
	 }
	 elseif($id=="6")
	 {
	    $sql=mysql_query("Select laptop_name ,laptop_model,box_no,serial_no,depot_location,laptop_type from laptop_details where laptop_type='D' order by depot_location ASC");
	 }
	 elseif($id=="7")
	 {
	    $sql=mysql_query("SELECT laptop_name, laptop_model, box_no, serial_no, depot_location, laptop_type  FROM laptop_details WHERE laptop_type = 'L' ORDER BY depot_location ASC ");
	 }
	 else
	 {
	     
	 }
   /*$sql=mysql_query("Select laptop_name ,laptop_model,box_no,serial_no,depot_location,laptop_type from laptop_details where status='1' OR status='2'");*/
   $i=1;
   $data.='<table border="0" class="grid" width="980"><tr>
						<th><b>Laptop Name</b></th>
						<th><b>Laptop Model</b></th>
						<th><b>Laptop Serial Number</b></th>
						<th><b>Box Number</b></th>
						<th><b>Depot Location</b></th>
						<th><b>Laptop Type</b></th>
						</tr>';
		if(mysql_num_rows($sql)>0)
		   {
		while($row=mysql_fetch_array($sql))
		    {
	                    $data .= '<tr class="odd">
						<td align="center">'.$row[0].'</td>
						<td align="center">'.$row[1].'</td>
						<td align="center">'.$row[3].'</td>
						<td align="center">'.$row[2].'</td>
						<td align="center">'.$row[4].'</td>';
						if($row[5]=='S')
						 {
						   $data .='<td align="center">Substitute</td>';
						 } 
						 elseif($row[5]=='O')
						 {
						    $data .='<td align="center">Original</td>';
						 }
						 elseif($row[5]=='X')
						 {
						    $data .='<td align="center">Retained</td>';
						 }
						 elseif($row[5]=='L')
						 {
						     $data .='<td align="center">Lost</td>';
						 }
						 elseif($row[5]=='D')
						 {
						    $data .='<td align="center">Damaged</td>';
						 }
						
						$data.='</tr>';
						$i++; 
			}
						$data.='
                 <table align="center">
                   <tr>
                     <td valign="top" colspan="2" align="center">
			         <input type="hidden" name="mode" value="laptopindepot" id="laptopindepot"/>
					 <input type="hidden" name="laptypeid" id="laptypeid" value="'.$id.'"> 
					 <input type="submit" value="Save details in excel" class="submit-butt" name="submit" onClick="return downloadLaptopDepotData()"/>
					 <input type="button" value="Cancel" class="submit-butt" onClick="javascript:location.href=\'laptop_depot.php\'">
              &nbsp;</td>
			  </tr>
			  </table>';
			  }
			  else
			  {
			    $data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
			  }
			  return $data;
}
    


?>